package com.ms.p2p.service.impl;


import com.ms.p2p.dao.ArticleCategoryDao;
import com.ms.p2p.entity.content.ArticleCategory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ArticleCategoryServiceImpl {

	@Autowired
	private ArticleCategoryDao articleCategoryDao;

	@Cacheable(value="articlecategory",key = "'list'")
	public List<ArticleCategory> getlist() {
		return articleCategoryDao.findAllList();

	}

	@Cacheable(value="articlecategory",key = "'id'+#id")
	public ArticleCategory get(String id) {
		return articleCategoryDao.get(id);
	}

	@CacheEvict(value="articlecategory",allEntries=true)
	public int insert(ArticleCategory articleCategory) {
		return articleCategoryDao.insert(articleCategory);
	}

	@CacheEvict(value="articlecategory",allEntries=true)
	public int update(ArticleCategory articleCategory) {
		return articleCategoryDao.update(articleCategory);
	}

	@CacheEvict(value="articlecategory",allEntries=true)
	public int del(Integer id) {
		return articleCategoryDao.deleteById(id);
	}
	@Cacheable(value="articlecategory",key = "'cate_name'+#cate_name")
	public ArticleCategory getByCateName(String cate_name) {
		return articleCategoryDao.findByCate_name(cate_name);
	}
}
